//
//  TaskTableViewCell.m
//  Civacrm
//
//  Created by 王桂敏 on 2017/2/8.
//  Copyright © 2017年 王桂敏. All rights reserved.
//

#import "TaskTableViewCell.h"


@interface TaskTableViewCell ()

@property (nonatomic,strong) NSArray *taskTypeArray;

@property (nonatomic,strong) UIView *bgView;

@end

@implementation TaskTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.taskTypeArray = @[@"",@"",@"",@"实训课"];
        [self initView];
    }
    return self;
}
- (void)initView{
    self.backgroundColor = WhiteColor;
    
    self.taskTypeLabel = [UILabel labelWithTitle:nil frame:CGRectMake(w(19), h(19), w(80), h(32)) font:font(22) textColor:ColorWithHexString(@"41c3ff") bgColor:WhiteColor];
    self.taskTypeLabel.layer.masksToBounds = YES;
    self.taskTypeLabel.layer.cornerRadius = w(5);
    self.taskTypeLabel.textAlignment = NSTextAlignmentCenter;
    self.taskTypeLabel.layer.borderColor = ColorWithHexString(@"41c3ff").CGColor;
    self.taskTypeLabel.layer.borderWidth = 1;
    [self addSubview:self.taskTypeLabel];
    
    self.taskNameLabel = [UILabel labelWithTitle:nil frame:CGRectMake(getMaxX(self.taskTypeLabel) + w(11), self.taskTypeLabel.y, kScreenWidth - getMaxX(self.taskTypeLabel) - w(11), self.taskTypeLabel.height) font:font(32) textColor:ColorWithHexString(@"4e778f") bgColor:WhiteColor];
    self.taskNameLabel.textAlignment = NSTextAlignmentLeft;
    [self addSubview:self.taskNameLabel];
    
    self.taskContentLabel = [UILabel labelWithTitle:nil frame:CGRectMake(self.taskTypeLabel.x, getMaxY(self.taskTypeLabel) + h(20), kScreenWidth - w(19) * 2 - w(15), h(24)) font:font(24) textColor:ColorWithHexString(@"a0c0d2") bgColor:WhiteColor];
    self.taskContentLabel.textAlignment = NSTextAlignmentLeft;
    self.taskContentLabel.numberOfLines = 1;
    [self addSubview:self.taskContentLabel];
    
    [self addLineWithLineWidth:1 startPoint:CGPointMake(w(21), h(119)) endPoint:CGPointMake(kScreenWidth - w(21), h(119)) lineColor:ColorWithHexString(@"f2f9fa")];
    
    self.usersView = [[CollectionView alloc] initViewWithType:CollectionViewType0 frame:CGRectMake(w(25) / 2, h(120), kScreenWidth - w(25), h(112))];
    
    
    self.bgView = [UIView viewWithFrame:CGRectMake(0, getMaxY(self.usersView), kScreenWidth, h(20)) bgColor:GlobalBgColor];
    [self addSubview: self.bgView];
    
    self.accessoryView = [UIImageView imageViewWithFrame:CGRectMake(0, 0, w(15), h(26)) image:@"icon_jinru"];
}

- (void)configCellWithMode:(CourseModel *)model{
    [self.usersView removeFromSuperview];
    self.taskTypeLabel.text = self.taskTypeArray[model.taskModel.taskType.integerValue];
    self.taskNameLabel.text = model.taskModel.taskName;
    self.taskContentLabel.text = model.taskModel.taskDesc;
    if (model.userInfoArray.count) {
        [self.usersView setDataSource:model.userInfoArray];
        [self addSubview:self.usersView];
    }
}

-(void)layoutSubviews {
    [super layoutSubviews];
    self.accessoryView.y = h(120) / 2 - h(13);
    self.accessoryView.x = kScreenWidth - w(35);
    self.bgView.y = self.height - h(20);
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
